package com.rgp.serviceorder.controller;

import com.rgp.internalcommon.dto.OrderDto;
import com.rgp.internalcommon.dto.ResponseResult;
import com.rgp.serviceorder.pojo.Order;
import com.rgp.serviceorder.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-20 5:36
 */
@RestController
public class OrderController {

    @Autowired
    private OrderService orderService;

    @PostMapping("order/add")
    public ResponseResult addOrder(@RequestBody OrderDto orderDto){
        return orderService.addOrder(orderDto);
    }

    @GetMapping("/order/test/{id}")
    public ResponseResult<Order> testGetOrder(@PathVariable("id") Long id){
        return orderService.testGetOrderById(id);
    }

    //司机去接乘客
    @PostMapping("/order/to-pick-up-passenger")
    public ResponseResult toPickUpPassenger(@RequestBody OrderDto orderDto){
        return orderService.toPickUpPassenger(orderDto);
    }

    //司机到达乘客上车点
    @PostMapping("/order/driver-arrive-departure")
    public ResponseResult driverArriveDeparture(@RequestBody OrderDto orderDto){
        return orderService.driverArriveDeparture(orderDto);
    }

    //司机接到乘客，乘客上车
    @PostMapping("/order/pick-up-passenger")
    public ResponseResult pickUpPassenger(@RequestBody OrderDto orderDto){
        return orderService.pickUpPassenger(orderDto);
    }

    //乘客下车，行程结束
    @PostMapping("/order/passenger-get-off")
    public ResponseResult passengerGetoff(@RequestBody OrderDto orderDto){
        return orderService.passengerGetoff(orderDto);
    }

    //乘客完成支付，订单状态修改为完成
    @GetMapping("/order/finish-pay")
    public ResponseResult finishOrderPay(@RequestParam("orderId") String orderId){
        return orderService.finishOrderPay(orderId);
    }
}